﻿Ext.application({
    name: 'Wiztop',
    requires: [
        'Ext.MessageBox',
        'Wiztop.custom.MyLoadMask'
    ],
    views: ['Home', 'MeetingTopic',  'MyMeeting', 'MyMeetingComment'], // 'Ext.ux.panel.PDF'
    controllers: [
    'Home',
    'MeetingTopic',
    'MeetingDoc',
    'DocDetail',
    'WhiteBoard',
    'MeetingHistory',
    'MeetingHistoryTopic',
    'MeetingHistoryDoc',
    'HistoryDocDetail',
    'topic.TopicCollect',
    'topic.TopicDetail',
    'MyMeeting',
    'vote.MeetingVote',
    'summary.SummaryCollect',
    'summary.SummaryDetail'],
    launch: function () {
        // redraw image when orientation is changed. 
        Ext.getDom('ext-viewport').addEventListener('orientationchange', function (viewport, orientation, width, height) {
            var pinchzooms = Ext.ComponentQuery.query('pinchzoomimage');
            for (var i = 0; i < pinchzooms.length; i++) {
                pinchzooms[i].redraw();
            }
        }, this, { buffer: 50 });
        //获取url查询字符串参数    
        var rq = window.location.search.substring(1);
        var ps = rq.split('&');
        sessionStorage.UserId = ps[0].split('=')[1];
        sessionStorage.RoleId = ps[2].split('=')[1];
        sessionStorage.UserTitle = decodeURI(ps[3].split('=')[1]);
        sessionStorage.UserName = decodeURI(ps[1].split('=')[1]);
        //初始化同步状态
        sessionStorage.Sync = false;
        //Initialize the main view
        Ext.Viewport.add(Ext.create('Wiztop.view.Home'));
    },
    onUpdated: function () {
        Ext.Msg.confirm(
            "应用程序更新",
            "应用程序已经成功被更新到最新版本。是否重新加载?",
            function (buttonId) {
                if (buttonId === 'yes') {
                    window.location.reload();
                }
            }
        );
    }
});
